home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_macfs.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  4KB  |  92 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. import unittest
  5. import warnings
  6. warnings.filterwarnings('ignore', 'macfs.*', DeprecationWarning, __name__)
  7. import macfs
  8. import os
  9. import sys
  10. import tempfile
  11. from test import test_support
  12.  
  13. class TestMacfs(unittest.TestCase):
  14.     
  15.     def setUp(self):
  16.         fp = open(test_support.TESTFN, 'w')
  17.         fp.write('hello world\n')
  18.         fp.close()
  19.  
  20.     
  21.     def tearDown(self):
  22.         
  23.         try:
  24.             os.unlink(test_support.TESTFN)
  25.         except:
  26.             pass
  27.  
  28.  
  29.     
  30.     def test_fsspec(self):
  31.         fss = macfs.FSSpec(test_support.TESTFN)
  32.         self.assertEqual(os.path.realpath(test_support.TESTFN), fss.as_pathname())
  33.  
  34.     
  35.     def test_fsref(self):
  36.         fsr = macfs.FSRef(test_support.TESTFN)
  37.         self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
  38.  
  39.     
  40.     def test_fsref_unicode(self):
  41.         if sys.getfilesystemencoding():
  42.             testfn_unicode = unicode(test_support.TESTFN)
  43.             fsr = macfs.FSRef(testfn_unicode)
  44.             self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
  45.         
  46.  
  47.     
  48.     def test_coercion(self):
  49.         fss = macfs.FSSpec(test_support.TESTFN)
  50.         fsr = macfs.FSRef(test_support.TESTFN)
  51.         fss2 = fsr.as_fsspec()
  52.         fsr2 = fss.as_fsref()
  53.         self.assertEqual(fss.as_pathname(), fss2.as_pathname())
  54.         self.assertEqual(fsr.as_pathname(), fsr2.as_pathname())
  55.  
  56.     
  57.     def test_dates(self):
  58.         import time as time
  59.         fss = macfs.FSSpec(test_support.TESTFN)
  60.         now = int(time.time())
  61.         fss.SetDates(now, now + 1, now + 2)
  62.         dates = fss.GetDates()
  63.         self.assertEqual(dates, (now, now + 1, now + 2))
  64.  
  65.     
  66.     def test_ctor_type(self):
  67.         fss = macfs.FSSpec(test_support.TESTFN)
  68.         fss.SetCreatorType('Pyth', 'TEXT')
  69.         (filecr, filetp) = fss.GetCreatorType()
  70.         self.assertEqual((filecr, filetp), ('Pyth', 'TEXT'))
  71.  
  72.     
  73.     def test_alias(self):
  74.         fss = macfs.FSSpec(test_support.TESTFN)
  75.         alias = fss.NewAlias()
  76.         (fss2, changed) = alias.Resolve()
  77.         self.assertEqual(changed, 0)
  78.         self.assertEqual(fss.as_pathname(), fss2.as_pathname())
  79.  
  80.     
  81.     def test_fss_alias(self):
  82.         fss = macfs.FSSpec(test_support.TESTFN)
  83.  
  84.  
  85.  
  86. def test_main():
  87.     test_support.run_unittest(TestMacfs)
  88.  
  89. if __name__ == '__main__':
  90.     test_main()
  91.  
  92.